from typing import Optional
import datetime

from sqlalchemy import Column, DateTime, Index, Integer, String, text
from sqlalchemy.dialects.mysql import TINYINT
from sqlmodel import Field, SQLModel

class Sentences(SQLModel, table=True):
    __table_args__ = (
        Index('id', 'id', unique=True),
    )

    id: int = Field(sa_column=Column('id', Integer, primary_key=True))
    create_time: Optional[datetime.datetime] = Field(default=None, sa_column=Column('create_time', DateTime))
    update_time: Optional[datetime.datetime] = Field(default=None, sa_column=Column('update_time', DateTime))
    is_deleted: Optional[int] = Field(default=None, sa_column=Column('is_deleted', TINYINT, server_default=text("'0'")))
    en_content: Optional[str] = Field(default=None, sa_column=Column('en_content', String(255, 'utf8mb4_unicode_ci'), server_default=text("''''''")))
    zh_content: Optional[str] = Field(default=None, sa_column=Column('zh_content', String(255, 'utf8mb4_unicode_ci'), server_default=text("''''''")))


class Voices(SQLModel, table=True):
    __table_args__ = (
        Index('id', 'id', unique=True),
        {'comment': '读音'}
    )

    id: int = Field(sa_column=Column('id', Integer, primary_key=True))
    object_id: Optional[int] = Field(default=None, sa_column=Column('object_id', Integer))
    gender: Optional[int] = Field(default=None, sa_column=Column('gender', TINYINT, server_default=text("'-1'"), comment='男-0，女-1'))
    ageType: Optional[int] = Field(default=None, sa_column=Column('ageType', TINYINT, server_default=text("'-1'"), comment='成人-0，小孩-1'))
    voice_url: Optional[str] = Field(default=None, sa_column=Column('voice_url', String(255, 'utf8mb4_unicode_ci'), server_default=text("''''''")))
    object_type: Optional[int] = Field(default=None, sa_column=Column('object_type', TINYINT, server_default=text("'-1'"), comment='单词-0，句子-1'))
    is_deleted: Optional[int] = Field(default=None, sa_column=Column('is_deleted', TINYINT, server_default=text("'0'")))
    update_time: Optional[datetime.datetime] = Field(default=None, sa_column=Column('update_time', DateTime))
    create_time: Optional[datetime.datetime] = Field(default=None, sa_column=Column('create_time', DateTime))


class WordMeanings(SQLModel, table=True):
    __tablename__ = 'word_meanings'
    __table_args__ = (
        Index('id', 'id', unique=True),
    )

    id: int = Field(sa_column=Column('id', Integer, primary_key=True))
    word_id: Optional[int] = Field(default=None, sa_column=Column('word_id', Integer))
    type: Optional[int] = Field(default=None, sa_column=Column('type', TINYINT, server_default=text("'-1'")))
    translation: Optional[str] = Field(default=None, sa_column=Column('translation', String(255, 'utf8mb4_unicode_ci'), server_default=text("''''''")))
    update_time: Optional[datetime.datetime] = Field(default=None, sa_column=Column('update_time', DateTime))
    create_time: Optional[datetime.datetime] = Field(default=None, sa_column=Column('create_time', DateTime))
    is_deleted: Optional[int] = Field(default=None, sa_column=Column('is_deleted', TINYINT, server_default=text("'0'")))


class Words(SQLModel, table=True):
    __table_args__ = (
        Index('id', 'id', unique=True),
        {'comment': '单词表'}
    )

    id: int = Field(sa_column=Column('id', Integer, primary_key=True))
    spell: Optional[str] = Field(default=None, sa_column=Column('spell', String(30, 'utf8mb4_unicode_ci'), server_default=text("''''''"), comment='单词拼写'))
    spell_split: Optional[str] = Field(default=None, sa_column=Column('spell_split', String(35, 'utf8mb4_unicode_ci'), server_default=text("''''''"), comment='单词按音 节拆分'))
    phonetic_symbol: Optional[str] = Field(default=None, sa_column=Column('phonetic_symbol', String(30, 'utf8mb4_unicode_ci'), server_default=text("''''''")))
    pic: Optional[str] = Field(default=None, sa_column=Column('pic', String(255, 'utf8mb4_unicode_ci'), server_default=text("''''''"), comment='图片地址'))
    is_deleted: Optional[int] = Field(default=None, sa_column=Column('is_deleted', TINYINT, server_default=text("'0'")))
    create_time: Optional[datetime.datetime] = Field(default=None, sa_column=Column('create_time', DateTime))
    update_time: Optional[datetime.datetime] = Field(default=None, sa_column=Column('update_time', DateTime))